package com.bawei.caohao0802.model.util

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create
import java.util.concurrent.TimeUnit

/**
 * 作者: 曹浩
 * 时间: 2024/8/2
 * 功能描述:
 */
class HttpUtils private constructor(){
    companion object{
        val httpUtils:HttpUtils by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED){
            HttpUtils()
        }
    }
    var retrofit=Retrofit.Builder()
        .baseUrl("http://10.59.9.24/")
        .client(OkHttpClient.Builder()
            .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
            .connectTimeout(5,TimeUnit.SECONDS)
            .readTimeout(5,TimeUnit.SECONDS)
            .build())
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .build()
    var server=retrofit.create<ApiServer>()
}